#include "UUnitOrBuildingType.h"
#include "../UIniFile/UIniFile.h"
#include "../UTextureManager.h"
#include "../UOBJLoader.h"
using namespace std;

TUnitOrBuildingType::TUnitOrBuildingType(TIniFile* inifile )
{
	HasModel = false;
	Name = inifile->getValue("UnitOrBuilding", "Name");
	Icon = GTextureManager->getTexture(inifile->getValue("UnitOrBuilding", "Icon"));
	string Model = inifile->getValue("Building", "Model");
	if (!Model.empty())
	{
		//FIXME: Maybe get a model manager (similar to texture manager)
		Model = "Data/Models/" +  Model;
		TOBJLoader OBJLoader;
		TypeModel = OBJLoader.loadModelFromFile(Model);
		HasModel = true;
	}

	Width = 2;//TODO: Read from ini file
	Height = 2;//TODO: Read from ini file
}








TUnitType::TUnitType(TIniFile* inifile)
	:	TUnitOrBuildingType(inifile)
{
	WindowTag = LastWindowTypeUnits++;
}




TBuildingType::TBuildingType(TIniFile* inifile)
	:	TUnitOrBuildingType(inifile)
{
	WindowTag = LastWindowTypeBuildings++;
}

